package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.ReturnProgressResponse
import com.gexiaobao.pigeon.databinding.ItemReturnProgressBinding

/**
 * @Author      : hxw
 * @Date        : 2023/7/10 13:42
 * @Describe    :
 */
class ReturnProgressAdapter(data: ArrayList<ReturnProgressResponse.ListData>) :
    BaseQuickAdapter<ReturnProgressResponse.ListData, DataBindBaseViewHolder>(R.layout.item_return_progress, data) {

    override fun convert(holder: DataBindBaseViewHolder, item: ReturnProgressResponse.ListData) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemReturnProgressBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        if (holder.layoutPosition == 0) {
            holder.setVisible(R.id.lineTop, false)//隐藏
        } else {
            holder.setVisible(R.id.lineTop, true)
        }

        if (item.status == 7 || item.status == 3) {
            holder.setGone(R.id.lineBottom, true)
        } else {
            holder.setGone(R.id.lineBottom, false)
        }
        holder.setGone(R.id.tvReturnReason, item.status != 3)

        val process = when (item.status) {
            1 -> context.getString(R.string.lease_wait_for_the_refund)//"您的退货申请商家已审核通过，请等待退款" //审核通过
            2 -> context.getString(R.string.lease_wait_for_merchant_review)//"您的退货申请已提交，请等待商家审核"
            3 -> context.getString(R.string.Your_return_request_has_been_denied)//"您的退货申请被驳回，若要继续申请点击下方按钮重新提交"
            7 -> context.getString(R.string.Refund_completed)//"退款已完成，可在我的余额中查看"
            11 -> context.getString(R.string.Wait_for_the_merchant_to_confirm_receipt) //"等待商家确认收货"
            else -> ""
        }
        holder.setText(R.id.tvItemReviewsStatus, process)
    }
}